package com.ldp.designpatterns.study.state.context;

import com.ldp.designpatterns.study.state.impl.CloseState;
import com.ldp.designpatterns.study.state.service.ElevatorState;

/**
 * @ClassName Elevator TODO context类
 * @Description TODO 当一个对象的行为在不同状态下发生改变，并且对象需要根据其状态执行不同的操作时，就可以考虑使用状态模式。
 * @Author lindipei
 * @Date 2023/10/18 16:45
 */
public class Elevator {
    private ElevatorState state;

    public Elevator() {
        state = new CloseState(); // 初始状态为关门状态
    }

    public void setState(ElevatorState state) {
        this.state = state;
    }

    public void openDoors() {
        state.openDoors();
    }

    public void closeDoors() {
        state.closeDoors();
    }

    public void move() {
        state.move();
    }

    public void stop() {
        state.stop();
    }

}
